<?php


namespace app\common\model;


use think\Model;
use app\common\model\OperationLog as operationLogModel;

class OperationLog extends Model {

    protected $pk = 'id';
    protected $append = ['admin_name'];



    public function getAdminNameAttr($value,$data){
        return Admin::where('admin_id',$data['admin_id'])->value('admin_name');
    }

    public function getCreatedAtAttr($value,$data){
        if(!empty($value)){
            return date('Y-m-d h:i:s',$value);
        }
    }

    //常规方法
    public function getLastLog(){
        $logModel = new operationLogModel();
        return json(gsuc($logModel->order('id','desc')->paginate(10)));
    }


}